extends Node2D


# Declare member variables here. Examples:
# var a = 2
# var b = "text"
#默认水分饱腹度
export var to_add_water=0
#默认食物饱腹度
export var eat_add_value=10

func _ready():
	#同步数据
	$LayerHud/Hud/Drink.value=Global.drink_value
	$LayerHud/Hud/Food.value=Global.eat_value
	$LayerHud/Hud/children.max_value=9000
	pass
# warning-ignore:unused_argument
func _process(delta):
	if Global.canMake:
		$LayerAction/Action/action.show()
	else:
		$LayerAction/Action/action.hide()
	pass
func _on_Enter_pressed():
	if Global.now_col_obj_name=="home":
# warning-ignore:return_value_discarded
		get_tree().change_scene("res://Scenes/zhanglangwo.tscn")
	if Global.now_col_obj_name=="desk":
		var shape=Global.now_col_obj.get_node("shape")
		print_debug("到桌子上")
		#print_debug(shape)
		shape.disabled=true
	
	pass # Replace with function body.

#喝水
func _on_Drink_pressed():
	#to_add_water+=10
	if Global.canDrink==true:
		$LayerHud/Hud/Drink.value+=10
		Global.drink_value+=10
		if Global.drink_value>=100:
			Global.tip_action="去繁殖"
	pass # Replace with function body.
#吃食物
func _on_Eat_pressed():
	if Global.now_col_obj_name=="food":
		#var shape=Global.now_col_obj.get_node("shape")
		print_debug("碰到食物")
		$LayerHud/Hud/Food.value+=10
		Global.eat_value+=10
		if Global.eat_value>=30:
			#切换教程全局状态机
			Global.tip_action="去喝水"
			print_debug("当前教程状态>",Global.tip_action)
			pass
	pass # Replace with function body.
#繁殖
func _on_action_pressed():
	print_debug("点击了繁殖按钮")
	Global.children_number+=Global.to_add_make_child
	#计算百分比 值/9999
	#var percent=Global.children_number/800

	$LayerHud/Hud/children.value=Global.children_number
	print_debug("当前数量",Global.children_number)
	pass # Replace with function body.
